using System.Reflection;
using System.Configuration;

using BCB.SQLServerDAL;

namespace BCB.DALFactory
{
    /// <summary>
    /// This class is implemented following the Abstract Factory pattern to create the DAL implementation
    /// specified from the configuration file
    /// </summary>
    public sealed class DataAccess
    {
        // Look up the DAL implementation we should be using
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];

        private DataAccess() { }

        public static BCB.IDAL.ICategory CreateCategory()
        {
            string className = path + ".Category";
            return (IDAL.ICategory)Assembly.Load(path).CreateInstance(className);
        }
        public static BCB.IDAL.IProduct CreateProduct()
        {
            string className = path + ".Product";
            return (IDAL.IProduct)Assembly.Load(path).CreateInstance(className);
        }

    }
}
